<template>
  <div class="box">
    <header class="need-header">
      <mt-header title="宝宝必备">
        <router-link to="/products" slot="left">
          <mt-button icon="back"></mt-button>
        </router-link>
        <mt-button class="iconfont icon-ai-search" slot="right"></mt-button>
      </mt-header>
    </header>
    <div class="need-content">
      <div class="need-banner">
      </div>
      <div class="need-list">
        <ul>
          <li @click="toDetail">
            <img src="https://g-search2.alicdn.com/img/bao/uploaded/i4/i4/2207271360/O1CN01DQxzpD1Luv8FbevyX_!!0-item_pic.jpg_360x360Q90.jpg_.webp" alt="">
            <h2>全球500强选材的纸尿裤</h2>
            <p>德国巴斯夫、日本住友吸水高分子</p>
            <span>会员价：￥999</span>
            <div class="tips">宝马亲测：真的很好用，不但薄而且吸收量很大，还没有红屁屁...</div>
            <i>0</i>
          </li>
          <li @click="toDetail">
            <img src="https://g-search2.alicdn.com/img/bao/uploaded/i4/i4/2207271360/O1CN01DQxzpD1Luv8FbevyX_!!0-item_pic.jpg_360x360Q90.jpg_.webp" alt="">
            <h2>全球500强选材的纸尿裤</h2>
            <p>德国巴斯夫、日本住友吸水高分子</p>
            <span>会员价：￥999</span>
            <div class="tips">宝马亲测：真的很好用，不但薄而且吸收量很大，还没有红屁屁...</div>
            <i>1</i>
          </li>
          <li @click="toDetail" v-for="(item, index) in prolist" :key="index+1">
            <img :src="item.media" alt="">
            <h2>{{item.proname}}</h2>
            <p>{{item.info}}</p>
            <span>会员价：￥{{item.vprice}}</span>
            <div class="tips">{{item.fav}}</div>
            <i>{{index+1}}</i>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
import Qs from 'qs'
import Vue from 'vue'
import { Search } from 'mint-ui'
Vue.component(Search.name, Search)
export default {
  data () {
    return {
      prolist: []
    }
  },
  created () {
    let data1 = {
      token: '7qwN83Y2xI2xasQikfLHvwFwLQKxxk5wZyi6Ej+So2Vx1864is3FP2c+zr18HzNAC7fzHZHbmLDWwJraATqJ+cjyp9aSekyCKPoiVit0kHqEJYNu3/HhVAqSW1YJBo9GtG4aH2RSdJ194HC4Slo8wLMBKgvd61ZSGeyJJ80HEnPtUff6/csmpBFsSlXoVRN+DygYwJsRRi2im1HkL0zDJr9GL1nJSxfJLr2+3dEGuEGyDJYuS6aGVaSzY7BCGX2OBspUNJw5BuYR/t3hvUWPCYbfCSehfNHALihJVTJ39LLJ9d/uyc4ciyBA5ZbusTst',
      tid: 4,
      pageNum: 1,
      pageSize: 5
    }
    // 宝宝必备商品区
    axios({
      method: 'post',
      url: 'http://47.99.223.44:8081/productbytid.do',
      data: Qs.stringify(data1)
    })
      .then((res) => {
        console.log(res)
        const obj = res.data.list
        this.prolist = obj
        console.log(this.prolist)
      })
      .catch(function (error) {
        console.log(error)
      })
  },
  methods: {
    toDetail () {
      this.$router.push('/prodetail')
    }
  }
}
</script>

<style lang="scss">
@import '@/lib/reset.scss';
.need-header {
  @include rect(100%, 0.4rem);
  text-align: center;
  box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 1);
  font-family: Arial;
  border: 1px solid rgba(255, 255, 255, 0);
  border: none;
  .mint-header {
    // background-color: rgb(226, 226, 226);
    height: 100%;
    background-color: #FFFADA;
    h1, .mint-header-button{
      color: rgba(100, 100, 100, 1);
      font-size: 0.16rem;
      .mintui-back {
        font-weight: 900;
      }
    }
  }
}
.need-content {
  overflow: auto;
  .need-banner {
    @include rect(100%, 1.4rem);
    background: #FFFADA;
  }
  .need-list {
    @include rect(95%, auto);
    margin-top: -0.8rem;
    margin-left: 0.14rem;
    ul {
      height: auto;
      li {
        width: 3.47rem;
        height: 1.49rem;
        line-height: 0.17rem;
        border-radius: 0.12rem;
        background-color: rgba(223, 223, 223, 1);
        color: rgba(166, 164, 164, 1);
        font-size: 0.12rem;
        box-shadow: 0px 0px 0px 0px rgba(255, 255, 255, 1);
        font-family: Arial;
        border: 1px solid rgba(255, 255, 255, 0);
        margin-bottom: 0.2rem;
        background: rgb(252, 244, 244);
        position: relative;
        img {
          margin: 0.2rem 0.16rem;
          width: 1.11rem;
          height: 1.08rem;
          line-height: 0.20rem;
          text-align: center;
          border: 1px solid rgba(187, 187, 187, 1);
          float: left;
        }
        h2 {
          color: #333;
          line-height: 0.2rem;
          margin-top: 0.17rem;
          font-size: 0.14rem;
        }
        p {
          line-height: 0.25rem;
          color: #666;
        }
        span {
          display: inline-block;
          line-height: 0.25rem;
          font-size: 0.14rem;
          color: rgb(243, 74, 74);
          font-family: Arial;
          font-weight: 600;
        }
        .tips {
          margin-top: 0.05rem;
        }
        i {
          position: absolute;
          top: 0.1rem;
          left: 0.05rem;
          @include rect(0.2rem, 0.2rem);
          border: 1px solid #5c5c5c;
          border-radius: 50%;
          text-align: center;
          line-height: 0.2rem;
          font-size: 0.14rem;
          color: #5c5c5c;
        }
      }
    }
  }
}

</style>
